package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.AdminImGroupRuleAddDTO;
import com.sc.nft.entity.dto.AdminImGroupRuleUpdateDTO;
import com.sc.nft.entity.vo.AdminGroupRuleVO;
import com.sc.nft.service.ImGroupRuleService;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("admin/imRule")
@Api(tags = "用户加群群组创建规则.")
public class ImGroupRuleController {

    private final ImGroupRuleService imGroupRuleService;

    @ApiOperation(value = "新增规则", notes = "新增规则", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result add(@RequestBody AdminImGroupRuleAddDTO adminImGroupRuleAddDTO) {
        imGroupRuleService.add(adminImGroupRuleAddDTO);
        return Result.success();
    }

    @ApiOperation(value = "获取数据列表", notes = "获取数据列表 ", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getList", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<AdminGroupRuleVO> getList(@RequestBody PageRequest pageRequest) {

        return PageResult.success(imGroupRuleService.getList(pageRequest));
    }

    @ApiOperation(value = "修改", notes = "修改", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/modifier", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result modifier(@RequestBody AdminImGroupRuleUpdateDTO adminModifierGroupDTO) {
        imGroupRuleService.update(adminModifierGroupDTO);
        return Result.success();
    }

}
